package com.twu.biblioteca.repositories;

import com.twu.biblioteca.domain.LoginToken;
import com.twu.biblioteca.domain.User;
import com.twu.biblioteca.repositories.IUserRepository;

import java.util.HashMap;
import java.util.Map;

public class LibraryUserRepository implements IUserRepository {

    Map<LoginToken, User> users;

    public LibraryUserRepository(){
        this.users = new HashMap<LoginToken, User>();

        fillUsers();
    }

    private void fillUsers(){
        users.put(new LoginToken("111-1111", "12345"), new User("Pedro", "pvereza@email.com", "9999-9999"));
        users.put(new LoginToken("111-1112", "6789"), new User("Lucas", "lucas@email.com", "8888-8888"));
        users.put(new LoginToken("111-1113", "0248"), new User("Paul", "paul@email.com", "3333-33335"));
    }

    @Override
    public User getUser(String libraryNumber, String password) {

        return users.get(new LoginToken(libraryNumber, password));
    }
}
